<template>
  <div>
    <span @click.stop="findOriginData($data.data)"
          style="cursor: pointer;text-decoration:underline;">{{ $data.data[$data.data.column.field] }}</span>
  </div>
</template>

<script>
import i18n from '@/i18n'
import thisStore from '@/store'
import { DataTransmit } from './dataTransmit'

export default {
  data () {
    return {
      gridThis: null
    }
  },
  created () {
    DataTransmit.$on('giveData', gridThis => {
      this.gridThis = gridThis
    })
  },
  methods: {
    i18nT (key) {
      return i18n.t(key)
    },
    getGirdData () {
      DataTransmit.$emit('needData')
    },
    findOriginData (data) {
      this.getGirdData()
      setTimeout(() => {
        if (this.$data.data.column.drillThrough.status && this.$data.data.column.drillThrough.pageid) {
          // let url = this.$data.data.column.drillThrough.url

          // try {
          //   if (url.substring(0, 4) === 'http') {
          //     window.open(url, '_blank')
          //   } else {
          //     router.push({
          //       path: url,
          //       query: { ...this.$data.data.column.drillThrough.data, ...this.$data.data.column, ...this.gridThis.slicer }
          //     })
          //   }
          // } catch (error) { }

          thisStore.state.drillThrough.pageid = this.$data.data.column.drillThrough.pageid + ''
          thisStore.state.drillThrough.data = { ...this.$data.data.column, ...this.gridThis.slicer, ...this.$data.data.column.drillThrough.data }
          this.$nextTick(() => {
            thisStore.state.drillThrough.dialogStatus = true
          })
        }
      }, 200)
    }
  },
  destroyed () {
    DataTransmit.$off('giveData')
  }
}
</script>

<style>
</style>
